Written by Jerry Aman, Optima System, July 28, 1996.
Part of the PageSpinner distribution.
Updated October 9, 1997.
We will not be held responsible for any unwanted
effects due to the usage of this script or any derivative.
No warrantees for usability for any specific application
are given or implied.
You are free to use and modify this script,
if all credits are kept in the source code
*/
function GetTodaysURL()
{
// Put relative or full URL's in the strings below
// First line is returned on Mondays, second on Tuesdays ...
// ... and the seventh on Sundays
var locationlist = new URLList
(
"groucho.html", // Monday
"harpo.html", // Tuesday
"zeppo.html",
"chico.html",
"harpo.html",
"groucho.html",
"chico.html" // Sunday
);
now = new Date();
num = now.getDay();
if (num == 0)
num = 7;
location.href = locationlist.list[num-1];
}
function URLList ()
{
var argv = URLList.arguments;
var argc = argv.length;
this.list = new Object();
for (var i = 0; i < argc; i++)
this.list[i] = argv[i];
this.count = argc;
return this;
}
// -- End of JavaScript code -------------- -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR=FFFFFF TEXT=000000>
<H1>JavaScript Today's Link</H1>
<B>This page contains a JavaScript that selects a different URL for each day of the
week</B>
<P>
Please note that JavaScript is currently only available in Netscape Navigator 2.0 or later, and in Internet Explorer for MacOS version 3.0.1 or later. <FONT COLOR="931B15">Do not assume that all in your audience are using a JavaScript enabled browser.</FONT>
<HR>
<P>
This JavaScript lets you present a different link to a different document URL for each day of the week.
<P>
You can use this to direct your readers to a different site each day of the week, or if you run a daily newsletter you can use it to let readers to go to a specific file depending on the day of the week.
<P>
The script is named <B>GetTodaysURL</B> and it is placed in the HEAD section of the HTML document. The script is executed by clicking on a link containing a call to GetTodaysURL(). Also note the <FONT COLOR="FF3366">custom text</FONT> in Netscape's status area.
<P>
Example of this script picking
<A HREF="javascript:GetTodaysURL()"
onMouseOver="window.status='This link takes you the page of the day!'; return true">todays</A> page. Another page will be displayed tomorrow.
<P>
<B>How to use:</B><BR>
Replace the filenames inside the script with your own URLs and edit this page contents inside the <BODY> section. (You can also copy the entire script to one of your existing pages).
<P>
<PRE>function GetTodaysURL()
{
// Put relative or full URL's in the strings below
// First line is returned on Mondays, second on Tuesdays ...
// ... and the seventh on Sundays
var locationlist = new URLList
(
"groucho.html", // Monday
"harpo.html", // Tuesday
"zeppo.html",
"chico.html",
"harpo.html",
"groucho.html",
"chico.html" // Sunday
);</PRE>
<P>
Use code similar to this to let the user execute the script:
<P>
<PRE><A HREF="javascript:GetTodaysURL()"
onMouseOver="window.status='This link takes you the page of the day!'; return true">Todays page</A></PRE>